﻿@using Competition.Domain.ValueObjects
@using Competition.Infrastructure
@model Competition.Admin.Web.Models.IntroductionViewModels.IntroductionViewModel
@{
    ViewData["Title"] = "Edit";
}

<div class="page-container">
    <form method="post" class="form form-horizontal ajaxForm" asp-action="Edit" asp-controller="Introduction" asp-route-id="@Model.Id" enctype="multipart/form-data">
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" asp-for="ClassId"></label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" asp-for="ClassId" asp-items="@(new SelectList(SysHelper.GetEnumDictionary(typeof(IntroductionEnum)),"Key","Value"))"></select>
                </span>
                <span class="c-red">*</span>
                <span asp-validation-for="ClassId"></span>
            </div>
            <div class="col-3">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" asp-for="Title"></label>
            <div class="formControls col-xs-8 col-sm-9">
                <input class="input-text" asp-for="Title">
                <span class="c-red">*</span>
                <span asp-validation-for="Title"></span>
            </div>
            <div class="col-3">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" asp-for="Description"></label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea class="textarea" asp-for="Description" datatype="*10-100" dragonfly="true" onKeyUp="$.Huitextarealength(this,200)"></textarea>
                <span asp-validation-for="Description"></span>
            </div>
            <div class="col-3">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" asp-for="Text"></label>
            <div class="formControls col-xs-8 col-sm-9">
                <div id="editor"></div>
                <span class="c-red">*</span>
                @Html.HiddenFor(model => model.Html)
                @Html.HiddenFor(model => model.Text)
                <span asp-validation-for="Text"></span>
            </div>
            <div class="col-3">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" asp-for="Status"></label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" asp-for="Status">
                        <option value="1">有效</option>
                        <option value="0">无效</option>
                    </select>
                </span>
                <span class="c-red">*</span>
                <span asp-validation-for="Status"></span>
            </div>
            <div class="col-3">
            </div>
        </div>

        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</div>

@section Scripts{
    <script type="text/javascript" src="https://unpkg.com/wangeditor@3.1.1/release/wangEditor.min.js"></script>
    <script>
        //加载方法
        $(function () {
            var E = window.wangEditor;
            var editor = new E('#editor');
            // 配置服务器端地址
            editor.customConfig.uploadImgServer = '@Url.Action("UploadImage","Upload")';
            editor.create();
            editor.txt.html($("#Html").val());

            $('div').on("click",'input[type=submit]',function(){
                $("#Html").val(editor.txt.html());
                $("#Text").val(editor.txt.text());
            });

        });
    </script>
}

